package org.darkforest.common.services.impl;

import org.darkforest.common.services.GoodsClassService;
import org.darkforest.dao.mapper.GoodsClassMapper;
import org.darkforest.model.GoodsClass;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2015/12/24.
 */
@Service
public class GoodsClassServiceImpl implements GoodsClassService {

    @Autowired
    private GoodsClassMapper goodsClassMapper;

    @Override
    public int deleteByPrimaryKey(Integer gcId) {
        return goodsClassMapper.deleteByPrimaryKey(gcId);
    }

    @Override
    public int insert(GoodsClass record) {
        return goodsClassMapper.insert(record);
    }

    @Override
    public int insertSelective(GoodsClass record) {
        return goodsClassMapper.insertSelective(record);
    }

    @Override
    public GoodsClass selectByPrimaryKey(Integer gcId) {
        return goodsClassMapper.selectByPrimaryKey(gcId);
    }

    @Override
    public int updateByPrimaryKeySelective(GoodsClass record) {
        return goodsClassMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(GoodsClass record) {
        return goodsClassMapper.updateByPrimaryKey(record);
    }

    /**
     * 查询商品分类
     *
     * @param goodsClass
     * @return
     */
    @Override
    public List<GoodsClass> findGoodsClass(GoodsClass goodsClass) {
        return goodsClassMapper.findGoodsClass(goodsClass);
    }

    /**
     *
     *
     * @param gcId
     * @param storeId 根据店铺ID查询店铺绑定分类
     * @param level   1 2 3 级
     * @return
     */
    public List<GoodsClass> findStoreBindClass(Integer storeId, Integer level,Integer gcId) {


        Map<String,Object> map  = new HashMap<String,Object>();
        map.put("storeId",storeId);
        map.put("class_"+level,level);
        map.put("gcId",gcId);
        return goodsClassMapper.findStoreBindClass(map);
    }
}
